package com.drinks.yiniang.adapter.community;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;

import com.chad.library.adapter.base.BaseViewHolder;
import com.drinks.yiniang.R;
import com.drinks.yiniang.adapter.base.BaseQuickRCVAdapter;
import com.drinks.yiniang.entity.common.IdNameListJson;

import java.util.List;

/**
 * 举报用理由列表adapter
 * @author han
 * @date 2019/8/30
 */
public class ReportUserAdapter extends BaseQuickRCVAdapter<IdNameListJson.IdNameListData, BaseViewHolder> {

    private Drawable mChooseFocusDrawable;
    private Drawable mChooseNormalDrawable;
    //当前选中的item
    private int mCurrentChoosePos = -1;

    public ReportUserAdapter(Context mContext, @Nullable List<IdNameListJson.IdNameListData> data) {
        super(R.layout.item_report_user, data);

        mChooseFocusDrawable = ContextCompat.getDrawable(mContext, R.mipmap.icon_choose_p);
        mChooseNormalDrawable = ContextCompat.getDrawable(mContext, R.mipmap.icon_choose_n);
    }

    @Override
    protected void convert(BaseViewHolder helper, IdNameListJson.IdNameListData item) {
        helper.setText(R.id.tv_report_user_reason, item.getName());

        if(helper.getAdapterPosition() == mCurrentChoosePos) {
            helper.setImageDrawable(R.id.iv_report_user_check, mChooseFocusDrawable);
        } else {
            helper.setImageDrawable(R.id.iv_report_user_check, mChooseNormalDrawable);
        }
    }

    public void setCurrentChoosePos(int mCurrentChoosePos) {
        this.mCurrentChoosePos = mCurrentChoosePos;
    }
}
